package com.itgacl.magic4j.modules.listener.mqtt;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Slf4j
@Component
public class MqttMessageListener implements IMqttMessageListener {

    @Override
    public void messageArrived(String topic, MqttMessage mqttMessage) {
        String dataMsg = new String(mqttMessage.getPayload(), StandardCharsets.UTF_8);
        log.debug("MqttMessageListener 【接收到mqtt消息】：[topic=[{}],qos=[{}] dataMsg=[{}]", topic, mqttMessage.getQos(), dataMsg);
    }
}
